package com.chen.serviceorder.controller;

import com.chen.internalcommon.dto.OrderInfo;
import com.chen.serviceorder.mapper.OrderInfoMapper;
import com.chen.serviceorder.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenLiuPing
 **/
@RestController
public class TestController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private OrderInfoMapper orderInfoMapper;

    @Value("${server.port}")
    private String port;

    /**
     * 并发测试实时订单
     * @param orderId
     * @return
     */
    @GetMapping("/test-real-time-order/{orderId}")
    public String dispatchRealTimeOrder(@PathVariable("orderId") long orderId) {
      //  System.out.println("start time:" + System.currentTimeMillis());
        System.out.println("并发测试 端口:" + port+ " orderId:" + orderId);
        OrderInfo orderInfo = orderInfoMapper.selectById(orderId);
         orderService.dispatchRealTimeOrder(orderInfo);
      //  System.out.println("end time:" + System.currentTimeMillis());
        return "test-real-time-order   success";

    }
}
